package com.wen.controller;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.wen.common.R;
import com.wen.pojo.Pay;
import com.wen.pojo.StockDetails;
import com.wen.pojo.dto.GatherDetailsDto;
import com.wen.pojo.vo.PayVo;
import com.wen.pojo.vo.StockDetailsVo;
import com.wen.service.StockDetailsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@CrossOrigin
@RestController
@RequestMapping("/stocks")
public class StockDetailsController {
    @Autowired
    private StockDetailsService service;

    @PostMapping("/page/{pageNum}/{pageSize}")
    public R page(@RequestBody StockDetailsVo stockDetailsVo, @PathVariable Long pageNum, @PathVariable Long pageSize){
        Page<StockDetails> payPage = service.pageListStockDetails(stockDetailsVo, pageNum, pageSize);
        return R.ok().data("files",payPage.getRecords()).data("total",payPage.getTotal())
                .data("current",payPage.getCurrent()).data("size",payPage.getSize());
    }

    @GetMapping("stocksById/{id}")
    public R gatherById(@PathVariable String id){
        List<GatherDetailsDto> gatherDetailsDto = service.GatherDetailsById(id);

        return R.ok().data("gatherDetailsDto",gatherDetailsDto);
    }
}
